package net.comm.file.db;


import java.sql.ResultSet;
import java.sql.SQLException;

import net.comm.file.bean.BaseFiles;
import net.comm.user.bean.BaseUsers;
import net.comm.user.service.impl.UsersServiceImpl;
import net.comm.util.StringUtil;

import org.apache.log4j.Logger;
import org.sakaiproject.db.api.SqlReader;

public class DbFilesService implements SqlReader
{
	static Logger logger = Logger.getLogger(DbFilesService.class.getName());
	/**
	 * Read from the result one set of fields to create a Resource.
	 * 
	 * @param result
	 *        The Sql query result.
	 * @return The Resource object.
	 */
	public Object readSqlResultRecord(ResultSet result)
	{
		try
		{
			String  f_ID = StringUtil.getValue(result.getString(1));	//	附件ID
			String  f_info = StringUtil.getValue(result.getString(2));	//	附件文件说明
			String  folder = StringUtil.getValue(result.getString(3));	//	附件所在文件夹
			String  f_name = StringUtil.getValue(result.getString(4));	//	附件文件名
			String  f_File2 = StringUtil.getValue(result.getString(5));	//	附件文件2
			int  	f_Num = result.getInt(6);							//	附件被引用次数
			String  f_Type = StringUtil.getValue(result.getString(7));	//	文件类型
			int  	f_Zip = result.getInt(8);							//	图片压缩情况
			int  	f_size = result.getInt(9);							//	附件大小
			String  mtime = StringUtil.getValue(result.getString(10));	//	最后修改日期

			// create the Resource from these fields
			return new BaseFiles(  f_ID,  f_info, folder, f_name, f_File2, f_Num, f_Type, f_Zip, f_size,  mtime);
		}
		catch (SQLException e)
		{
			logger.error(e.getMessage());
			return null;
		}
		
	}
}
